<template>
  <el-link v-bind="$attrs" @click="delClick">
    <slot v-for="(item, key) in $slots" :name="key"></slot>
  </el-link>
</template>

<script setup>
import { elAlert, elConfirm } from "../../ele-message";
import { useAttrs } from "vue";
const $attrs = useAttrs();
const delClick = () => {
  if ("onDelClick" in $attrs || "onAlertClick" in $attrs) {
    const params = {};
    if ($attrs.title) params.title = $attrs.title;
    if ($attrs.message) params.message = $attrs.message;
    const fun = "onDelClick" in $attrs ? elConfirm : elAlert;
    fun({
      ...params,
      confirm() {
        "onDelClick" in $attrs && $attrs.onDelClick();
        "onAlertClick" in $attrs && $attrs.onAlertClick();
      },
    });
  }
};
</script>
